package com.itheima.test;

public class MPDemo2 {
    public static void main(String[] args) {
        //创建一个数组
        int[] arr = new int[]{1, 6, 2, 84, 21, 30};
        for (int j = 0; j < 4; j++) {
            //对其进行遍历,将前两个值进行比对,转换
            for (int i = 0; i < arr.length - 1; i++) {
                if (arr[i] >= arr[i + 1]) {
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i+1] = temp;
                }
            }
        }
        printArr(arr);
    }

    public static void printArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
